package top.rushpeak.edu03.web.api;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import top.rushpeak.edu03.api.model.User;
import top.rushpeak.edu03.api.service.HelloService;

@Controller
public class HelloController {

	@Autowired
	private HelloService helloService;
	
	@ResponseBody
	@RequestMapping("/hello")
	public String say(){
		return "hello";
	}
	
	@ResponseBody
	@RequestMapping("/hs")	
	public String sayService(){
		System.out.println("111");
		return helloService.say();
	}
	
	@ResponseBody
	@RequestMapping("/hs/{username}")	
	public User userData(@PathVariable String username){
		System.out.println("2");
		return helloService.findUser(username);
	}
	
	@ResponseBody
	@RequestMapping("/hr/{username}")	
	public User userRedisData(@PathVariable String username){
		System.out.println("3");
		return helloService.findRedisUser(username);
	}
	
	@ResponseBody
	@RequestMapping("/mq/{msg}")	
	public void userMqData(@PathVariable String msg){
		System.out.println("4");
		helloService.testMQ(msg);
	}
	
	
}
